<template lang="pug">
  .page
    .AccountsReceivableManage
      .search-form.mb-10.pl-10.pr-10
        Form.ivu-row(ref="formData" :model="formData" :rules="rules" :label-width="90")
          Row.mb-15(type="flex" justify="start")
            Col.pr-20(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
              span.label-txt.w65 企业名称：
              Input(v-model="formData.customerName" placeholder="请输入企业名称" clearable)
            Col.pr-20(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
              span.label-txt.w100 身份证号码：
              Input(v-model="formData.idCardNo" placeholder="请输入身份证号码" clearable)
            Col(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
              Button(type="info" @click="searchFn") 查询
          //- FormItem.form-item.ivu-col.pr-20.mb-15(v-for="(item, index) of formItem" :label="item.label" :key="index" :class="item.style" :prop="item.prop")
          //-   template(v-if="item.type === 'input'")
          //-     Input(v-model="formData[item.model]" :placeholder="item.placeholder" clearable)
          //-   template(v-if="item.type === 'button'")
          //-     Button(type="info" @click="searchFn") 查询
      .pl-20.pr-20.bg-white
        Table.hasTitle-table.beautiful-table(:columns="thead" :data="tableData" :stripe="true" ref="demoTable")
          ._table_header(slot="header")
            .table-title-lefttxt.pull-left
              span.leftText
                | 合计:
                span.text-info.pl-5.pr-5.font-weight {{tableComone.totalRows}}
                | 条
          .clearfix.pl-20.pr-20(slot="footer")
            Page(
              :total="tableComone.totalRows"
              @on-change="onChangePage"
              @on-page-size-change="onpageSizeChange"
              show-sizer
              show-total
              placement="top"
              prev-text="上一页"
              next-text="下一页"
              :page-size-opts="[10, 20, 30, 50, 100]"
            )
</template>

<script>
import { EnumApi } from '@/api/Enum.api.js'
import { FinanceBasedataDetailApi } from '@/api/FinanceBasedataDetail.api.js'
// import { BalanceApi } from '@/api/Balance.api.js'
import { ServersDetailsThead } from './tableHead.js'
import _cloneDeep from 'clone-deep'
import { EmployeesApi } from '@/api/Employees.api.js'
import { Common } from '@/utils/common.js'

export default {
  name: '',

  components: {
  },

  data () {
    return {
      thead: _cloneDeep(ServersDetailsThead),
      tableData: [],
      formData: {
        customerName: '',
        idCardNo: ''
      },
      formItem: [
        { type: 'input', label: '企业名称：', placeholder: '请输入企业名称', prop: 'customerName', model: 'customerName', options: 'customer', style: 'ivu-col-span-md-24 ivu-col-span-lg-12 ivu-col-span-xl-8 ivu-col-span-xxl-6' },
        { type: 'input', label: '身份证号码：', placeholder: '请输入身份证号码', prop: 'idCardNo', model: 'idCardNo', options: 'customer', style: 'ivu-col-span-md-24 ivu-col-span-lg-12 ivu-col-span-xl-8 ivu-col-span-xxl-6' },
        { type: 'button', style: 'ivu-col-span-md-24 ivu-col-span-lg-12 ivu-col-span-xl-8 ivu-col-span-xxl-6' }
      ],
      rules: {},
      selectedEmployeeId: [], // 勾选的id集合,array格式
      selectedEmployeeArr: [], // 勾选的id, name数组集合
      tableComone: {
        pageIndex: 1, // 页码
        totalRows: 0, // 总条数
        pageSize: 10, // 当前页面展示条数
        inServiceCount: 0, // 在职
        outServiceCount: 0 // 离职
      },
      downLoadRul: '',
      arrListDown: {
        customer: []
      },
      datePickerDefault: new Date(), // 当前时间
      importExcel: {
        uploadLoading: false,
        progressPercent: 0,
        showProgress: false,
        showRemoveFile: false,
        file: null
      }
    }
  },
  computed: {
    // actionArr() {
    //   let arr = this.$store.state.user.actionAccess.map(item => {
    //     return item.code
    //   })
    //   return arr
    // },
    // // 导出
    // hasExport () {
    //   return this.actionArr.indexOf('ExportSocialSecurityBill') > -1
    // }
  },

  watch: {
  },

  mounted () {
    this.query()
  },

  methods: {
    /**
     * 分页页码变动
     * @param {Number} val pageIndex
     */
    onChangePage (val) {
      this.tableComone.pageIndex = val
      this.query()
    },
    /**
     * 分页页码变动
     * @param {Number} val pageSize
     */
    onpageSizeChange (val) {
      this.tableComone.pageIndex = 1
      this.tableComone.pageSize = val
      this.query()
    },

    // 搜索
    searchFn () {
      this.tableComone.pageIndex = 1
      this.query()
    },

    /**
     * 分页查询接口
     * @param {Object} obj {pageIndex, pageSize}
     */
    async query () {
      var params = {
        CustomerName: this.formData.customerName,
        IdCardNo: this.formData.idCardNo,
        OrderId: this.$route.query.id,
        PageIndex: this.tableComone.pageIndex,
        PageSize: this.tableComone.pageSize
      }
      let res = await FinanceBasedataDetailApi.getList(params)
      console.log('客户差额详情res: ', res)
      if (res.status === 200 && res.data.success) {
        this.tableData = res.data.data
        this.tableComone.totalRows = res.data.totalRows
      } else {
        this.tableData = []
      }
      this.loading = false
    },

    // 表格选择操作
    handleOnSelectChange (value) {
      this.selectedEmployeeArr = value.map((item) => {
        return { id: item.id, name: item.name }
      })
      this.selectedEmployeeId = value.map((item) => {
        return item.id
      })
      console.log('列表勾选数组1', this.selectedEmployeeArr)
      console.log('列表勾选数组2', this.selectedEmployeeId)
    }
  } // methods end
}
</script>

<style lang="less" scoped>

</style>
